package com.zds.zds_picture_backend.common;

import com.zds.zds_picture_backend.exception.ErrorCode;
import lombok.Data;

import java.io.Serializable;

/**
 * 通用返回结果类
 */
@Data
public class BaseResponse<T> implements Serializable {

    private int code;           // 状态码
    private T data;             // 返回数据
    private String message;     // 提示信息
    private String description; // 错误详细描述（可选）

    public BaseResponse(int code, T data, String message) {
        this(code, data, message, null);
    }

    public BaseResponse(int code, T data) {
        this(code, data, "", null);
    }

    public BaseResponse(ErrorCode errorCode) {
        this(errorCode.getCode(), null, errorCode.getMessage(), null);
    }

    public BaseResponse(int code, T data, String message, String description) {
        this.code = code;
        this.data = data;
        this.message = message;
        this.description = description;
    }

    public BaseResponse(int code, String message, String description) {
        this(code, null, message, description);
    }
}
